<?php

namespace AlibabaCloud\SDK\Sample;

use AlibabaCloud\SDK\Dysmsapi\V20170525\Dysmsapi;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Dysmsapi\V20170525\Models\SendSmsRequest;

class Sample {
	// 发送短信
	/*
	 * 新订单通知：SMS_225925355 {新订单提醒}-您好，军网平台有新的订单，单号：${order}，金额：${money}。地址：${address}。请及时处理。
	 * 到账通知：SMS_225910508 {客户款到账提醒}-尊敬的合作伙伴您好，军网平台订单，单号：${order}，金额：${money}。客户款已到账，请及时查看，如有疑问可点击系统质疑按钮。
	 * 付款通知：SMS_225935234 {货款支付提醒}-尊敬的合作伙伴您好，军网平台订单，单号：${order}，金额：${money}。货款已支付，请及时查看，如有疑问可点击系统质疑按钮。
	 */
	public function sendMsg($phone, $tpl_code, $param) {
		$client = self::createClient ();
		$sendSmsRequest = new SendSmsRequest ( [ 
				"signName" => "优士创新",
				"phoneNumbers" => $phone,
				"templateCode" => $tpl_code,
				"templateParam" => $param 
		] );
		// 复制代码运行请自行打印 API 的返回值
		$client->sendSms ( $sendSmsRequest );
	}
	public static function createClient() {
		$accessKeyId = 'LTAIeRWUxR6rp7sj';
		$accessKeySecret = 'n4qEWLCengJ012UAWl7UJvMOVMLgXY';
		$config = new Config ( [ 
				"accessKeyId" => $accessKeyId,
				"accessKeySecret" => $accessKeySecret 
		] );
		// 访问的域名
		$config->endpoint = "dysmsapi.aliyuncs.com";
		return new Dysmsapi ( $config );
	}
}